package homework;

import java.util.Scanner;
import java.util.Stack;

//作业标题(2739)
//二叉树的构建及遍历
//
//作业内容
//二叉树的构建及遍历
//https://www.nowcoder.com/practice/4b91205483694f449f94c179883c1fef?tpId=60&&tqId=29483&rp=1&ru=/activity/oj&qru=/ta/tsing-kaoyan/question-ranking
public class h2739 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextLine()) { // 注意 while 处理多个 case
            String str = in.nextLine();
            Stack<Character> stack = new Stack<>();
            for (int i = 0; i < str.length(); i++) {
                if (str.charAt(i) == '#') {
                    if (!stack.isEmpty()) System.out.print(stack.pop() + " ");
                } else {
                    stack.push(str.charAt(i));
                }
            }
            while (!stack.isEmpty()) {
                System.out.print(stack.pop() + " ");
            }
        }
    }

}
